﻿

@model DingTalkAgent.Model.T_MedicalArchives
@{
    ViewBag.Title = "Index";
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title style="color:#ffffff">新增客户</title>
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    @Html.Partial("_Common")
    <link href="~/dist/mui.picker.min.css" rel="stylesheet" />
    <script src="~/dist/mui.picker.min.js"></script>
    <style>
        .register form {
            padding: 20px 50px 40px 50px;
            -moz-border-radius: 8px;
            -webkit-border-radius: 8px;
            border-radius: 8px;
            -moz-box-shadow: 0 1px 5px 0 rgba(0,0,0,.3);
            -webkit-box-shadow: 0 1px 5px 0 rgba(0,0,0,.3);
            box-shadow: 0 1px 5px 0 rgba(0,0,0,.3);
            text-align: center;
            height: 100%;
        }

        .register {
            height: 100%;
        }

            .register form h2 {
                margin-bottom: 25px;
                padding-bottom: 15px;
                /*background: url(../img/pencil.png) 70px 6px no-repeat;*/
                border-bottom: 2px dotted #bbb;
                font-size: 30px;
                font-weight: 400;
                text-align: center;
            }

            .register form .input {
                width: 97%;
                height: 42px;
                background: #fcfcfc;
                border: 1px solid #ddd;
                -moz-border-radius: 2px;
                -webkit-border-radius: 2px;
                border-radius: 2px;
                -moz-box-shadow: 0 1px 3px 0 rgba(0,0,0,.1) inset;
                -webkit-box-shadow: 0 1px 3px 0 rgba(0,0,0,.1) inset;
                box-shadow: 0 1px 3px 0 rgba(0,0,0,.1) inset;
                font-family: 'PT Sans', Helvetica, Arial, sans-serif;
                color: #888;
                font-size: 18px;
            }

                .register form .input:focus {
                    border: 1px solid #ccc;
                    -moz-box-shadow: none;
                    -webkit-box-shadow: none;
                    box-shadow: none;
                }

            .register form label {
                margin: 7px 0 10px 5px;
                font-size: 16px;
                text-align: left;
            }

                .register form label span {
                    font-style: italic;
                }

            .register form input:-moz-placeholder {
                color: #aaa;
            }

            .register form input:-ms-input-placeholder {
                color: #aaa;
            }

            .register form input::-webkit-input-placeholder {
                color: #aaa;
            }

            .register form button {
                cursor: pointer;
                width: 60%;
                height: 42px;
                margin-top: 25px;
                padding: 0;
                background: #eb4141;
                -moz-border-radius: 3px;
                -webkit-border-radius: 3px;
                border-radius: 3px;
                border: 0;
                -moz-box-shadow: 0 15px 30px 0 rgba(255,255,255,.1) inset;
                -webkit-box-shadow: 0 15px 30px 0 rgba(255,255,255,.1) inset;
                box-shadow: 0 15px 30px 0 rgba(255,255,255,.1) inset;
                font-family: 'PT Sans', Helvetica, Arial, sans-serif;
                font-size: 16px;
                font-weight: 400;
                color: #fff;
                text-shadow: 0 1px 2px rgba(0,0,0,.1);
                -o-transition: all .2s;
                -moz-transition: all .2s;
                -webkit-transition: all .2s;
                -ms-transition: all .2s;
            }

                .register form button:hover {
                    -moz-box-shadow: 0 -15px 30px 0 rgba(255,255,255,.05) inset;
                    -webkit-box-shadow: 0 -15px 30px 0 rgba(255,255,255,.05) inset;
                    box-shadow: 0 -15px 30px 0 rgba(255,255,255,.05) inset;
                }

                .register form button:active {
                    -moz-box-shadow: 0 -15px 30px 0 rgba(255,255,255,.05) inset, 0 5px 8px 0 rgba(0,0,0,.1) inset;
                    -webkit-box-shadow: 0 -15px 30px 0 rgba(255,255,255,.05) inset, 0 5px 8px 0 rgba(0,0,0,.1) inset;
                    box-shadow: 0 -15px 30px 0 rgba(255,255,255,.05) inset, 0 5px 8px 0 rgba(0,0,0,.1) inset;
                }
    </style>
</head>
<body>
    <div class="register span6">
        <form id="editForm" action="" method="post" onsubmit="return false">
            <input type="text" class="input" id="hospitalName" name="hospitalName" aria-required="true" placeholder="就诊医院名称...">
            <input type="text" class="input" id="medicalTime" name="medicalTime" aria-required="true" placeholder="请选择就诊日期...">
            <textarea id="txt_remarks" name="remarks" class="input" style="height:70px;" placeholder="备注..."></textarea>
            <input type="hidden" name="customerId" value="@ViewBag.UserId" id="hid_id" />
            <button id="btn_Save" type="submit">保存</button>

        </form>
    </div>
    <script type="text/javascript" charset="utf-8">
        $(document).ready(function () {
            mui.init();
            var datepicker = mui('#medicalTime');
            datepicker.each(function (i, btn) {
                btn.addEventListener('tap', function () {
                    var dtPicker = new mui.DtPicker({
                        type: "date",
                        labels: ['年', '月', '日', '时', '分'],//设置默认标签区域提示语 
                    });
                    if ($("#medicalTime").val()) {
                        dtPicker.setSelectedValue($("#medicalTime").val())
                    }
                    dtPicker.show(function (item) {
                        $("#medicalTime").val(item.text);
                    });
                }, false);
            });
            
            //验证
            Validater = $("form").validate({
                rules: {
                    hospitalName: {
                        required: true,
                    },
                    medicalTime: {
                        required: true,
                        //minlength: 5
                        phone:true
                    },
                },
                messages: {
                    hospitalName: {
                        required: '<span style="color:red;font-size:14px;font-style:normal">请输入就诊医院名称</span>',
                    },
                    medicalTime: {
                        required: '<span style="color:red;font-size:14px;font-style:normal">请选择就诊日期</span>',
                    },
                }
            });
            $("#btn_Save").click(function () {
                if (Validater.form()) {
                    $.ajax({
                        type: "POST",
                        url: "/Customer/SaveArchives",
                        dataType: "JSON",
                        data: $('#editForm').serializeArray(),
                        success: function (data) {
                            if (data.status) {
                                alert(data.msg);
                                setTimeout(function () {
                                    window.location.href = '/mobile/Customer/Archives?customerId="+@ViewBag.UserId;
                                }, 500);
                            }
                        }, error: function () {
                            alert(data.msg);
                        }
                    });
                }
            });
        });
    </script>
</body>
</html>
